$(function() {
            alert(1111);
            $('#fresh').on('click', function() {
                    var r = Math.ceil(Math.random() * 5);
                    $.ajax({
                            url: 'http://www.iwjwdev2.com/morketing.cn?json=get_posts&cat=170&posts_per_page=5&page=' + r,
                            type: 'GET',
                            dataType: 'json'
                        })
                        .done(function(res) {
                            if (res.status == "ok") {
                                var html = template.render(contentsTpl)(res);
                                $('.visit-main').html(html);
                            } else {
                                 console.log(res.msg)
                            }
                        })
                        .fail(function(res) {
                            console.log('链接错误')
                        })
            })

            var contentsTpl = '' +
                '{{each posts as v i}}' +
                ' <dl class="clearfix">' +
                '    <dt class="f-l"><img src="{{v.attachments[0].url}}" alt=""></dt>' +
                '    <dd class="f-l"><a href="{{v.url}}">{{v.title_plain}}</a></dd>' +
                ' </dl>' +
                '{{/each}}'
})
